package com.sq.partner.manager.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.sq.partner.manager.dao.IGatewayRoleDeptDao;
import com.sq.partner.manager.mybatis.model.DeptDto;
import com.sq.partner.manager.mybatis.model.GatewayRole;
import com.sq.partner.manager.mybatis.model.GatewayRoleDept;

@Repository
public class GatewayRoleDeptDaoImpl extends BaseDaoImpl implements IGatewayRoleDeptDao {

	@Override
	public List<DeptDto> queryDeptDto(Long userid) throws Exception {
		Object obj = this.queryList("queryGatewayRoleDeptByUserid", userid);
		if(null!=obj){
			List<DeptDto> depts = (List<DeptDto>)obj;
			return depts;
		}
		return null;
	}

	@Override
	public List<DeptDto> queryDeptDtoByRoleId(Long roleId) throws Exception {
		Object obj = this.queryList("queryGatewayRoleDeptByRoleid", roleId);
		if(null!=obj){
			List<DeptDto> depts = (List<DeptDto>)obj;
			return depts;
		}
		return null;
	}

	
	@Override
	public boolean addDeptsToOneRole(GatewayRoleDept roleDept) throws Exception {
		return this.add("insertGatewayRoleDept", roleDept);
	}

	@Override
	public boolean delDeptsToOneRole(Long roleid) throws Exception {
		return this.delete("delGatewayRoleDeptByRoleid", roleid);
	}

	@Override
	public boolean updateRoleDeptInfo(GatewayRoleDept roleDept) throws Exception {
		return this.update("updateGatewayRoleDept", roleDept);
	}

}
